package com.gaofei.food.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gaofei.food.domain.TbFood;
import com.gaofei.food.service.MenuCateService;
import com.gaofei.food.service.TbFoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("food")
@CrossOrigin  //临时处理跨域问题,用网关的时候,把ta注释掉
public class FoodController {
    @Autowired
    private TbFoodService foodService;
    @Autowired
    private MenuCateService menuCateService;
    @RequestMapping("getFoodByCateId")
    public Object getFoodByCateId(Integer id){
        QueryWrapper<TbFood> qw = new QueryWrapper<>();
        qw.eq("menu_cate_id",id);
        List<TbFood> list = foodService.list(qw);
        return list;
    }
    @RequestMapping("cateList")
    public Object list(){
        return menuCateService.list();
    }
}
